import math
x1 = 0
y1 = 0
x2 = 0
y2 = 1
x3 = 1
y3 = 0
path_direction = math.atan2(y2 - y1, x2 - x1)
# path_direction = math.atan2(y3 - y1, x3 - x1)

# print(path_direction)
def projection_distance(A, B, C):#目标A,当前B,起点C
        # 提取点的坐标
        xA, yA = A
        xB, yB = B
        xC, yC = C
        
        # 计算向量AB和AC
        AB = (xB - xA, yB - yA)
        AC = (xC - xA, yC - yA)
        
        # 计算点积
        dot_product = AB[0] * AC[0] + AB[1] * AC[1]

        # 计算叉积
        cross_product = AB[0] * AC[1] - AB[1] * AC[0]
        
        # 计算向量AC的模
        magnitude_AC = math.sqrt(AC[0]**2 + AC[1]**2)
        
        # 计算投影距离
        projection_dist = dot_product / magnitude_AC

        # 计算点B到向量AC的距离
        cross_distance = cross_product / magnitude_AC
        
        return projection_dist,cross_distance

A = (1, 5)
B = (0.8, 0.3)
C = (1, 0)
 
# 计算投影距离
distance_direction,distance_cross = projection_distance(A, B, C)
# print(f"点A到点B的距离在AC方向上的投影距离是: {distance}")

print(f"点B到AC的距离是: {distance_cross}")